<!DOCTYPE html>
<html>
<head>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all">
  <script type="text/javascript" src="/static/layui/layui.js"></script>
  <style type="text/css">
    .header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
    .header div{border-bottom:solid 2px #009688;margin-top: 8px;}
    .header button{float:right;margin-top:-5px;}
  </style>
</head>
<body style="padding:10px; box-sizing: border-box;">
<form class="layui-form">
  <div class="layui-form-item" style="display:none;">
    <label class="layui-form-label">账户</label>
    <div class="layui-input-inline">
      <input type="text" class="layui-input" name="username" value="{$user}">
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">旧密码</label>
    <div class="layui-input-inline">
      <input type="password" class="layui-input" name="password" placeholder="请输入密码">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">新密码</label>
    <div class="layui-input-inline">
      <input type="password" class="layui-input" name="pass1" placeholder="请输入新密码">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">重复新密码</label>
    <div class="layui-input-inline">
      <input type="password" class="layui-input" name="pass2" placeholder="请再次输入新密码">
    </div>
  </div>
</form>
<div class="layui-form-item">
  <div class="layui-input-block">
    <button type="button" class="layui-btn" onclick="save()">修改</button>
  </div>
</div>
<script type="text/javascript">
  layui.use(['form'],function(){
    form = layui.form;
    $ = layui.jquery;
  });
  function save(){
    $.post(
            "/admin/user",
            $('form').serialize(),//序列化表单
            function(res){
              console.log(res);
              if (res.code==0) {
                layer.msg(res.msg,{"icon":1});
                setTimeout(function () {
                  top.location.href="/login";
                },1000)
              } else {
                layer.msg(res.msg,{"icon":2});
              }
            }, "json");
  }
</script>
</body>
</html>